#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int T,n,a[1000010],tag,x[500010];
string s;
int main()
{
	freopen("palin.in","r",stdin);
	freopen("palin.out","w",stdout);
	scanf("%d",&T);
	while(T--)
	{
		memset(a,0,sizeof(a)),memset(x,0,sizeof(x));
		scanf("%d%d",&n,&a[1]),a[0]=-1,a[2*n+1]=-1;
		for(int i=2,j=2*n;i<=j;++i)
		{
			scanf("%d",&a[i]);
			if(a[i]==a[1])tag=i;
		}
		int p1=tag,p2=tag,l=2,r=2*n,tot=1,flag=1;
		s="L",x[1]=a[1];
		while(tot<=n)
		{
			if(a[p1-1]==a[l])++l,--p1,s+="L",x[++tot]=a[p1];
			else if(a[p2+1]==a[l])++l,++p2,s+="L",x[++tot]=a[p2];
			else if(a[p1-1]==a[r])--r,--p1,s+="R",x[++tot]=a[p1];
			else if(a[p2+1]==a[r])--r,++p2,s+="R",x[++tot]=a[p2];
			else
			{
				flag=-1;
				break;
			}
			cout<<s<<endl;
		}
		if(flag==1)
		{
			for(int i=n;i>=1;--i)
			{
				if(x[i]==a[l])s+="L",++l;
				else if(x[i]==a[r])s+="R",--r;
				else
				{
					flag=-1;
					break;
				}
			}
		}
		else if(flag==-1)
		{
			for(int i=2*n-1;i>=1;--i)
			if(a[i]==a[2*n])
			{
				tag=i;
				break;
			}
			int p=tag,l=1,r=2*n-1,tot=1,flag=1;
			s="R",x[1]=a[1];
			while(tot<=n)
			{
				if(a[p1-1]==a[l])++l,--p1,s+="L",x[++tot]=a[p1];
				else if(a[p1-1]==a[r])--r,--p1,s+="R",x[++tot]=a[p1];
				else if(a[p2+1]==a[l])++l,++p2,s+="L",x[++tot]=a[p2];
				else if(a[p2+1]==a[r])--r,++p2,s+="R",x[++tot]=a[p2];
				else
				{
					flag=-1;
					break;
				}
			}
			if(flag==1)
			{
				for(int i=n;i>=1;--i)
				{
					if(x[i]==a[l])s+="L",++l;
					else if(x[i]==a[r])s+="R",--r;
					else
					{
						flag=-1;
						break;
					}
				}
			}
		}
		if(flag==1)cout<<s<<endl;
		else printf("-1\n");
	}
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}
/*
2
5
4 1 2 4 5 3 1 2 3 5
3
3 2 1 2 1 3
*/
